package com.yanqu.road.server.cmd.activity.autoreward.rank;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.entity.rank.UnionActivityRank;
import com.yanqu.road.entity.rank.cross.CrossUserRank;
import com.yanqu.road.logic.cross.CrossActivityRankListModel;
import com.yanqu.road.logic.cross.CrossActivityUnionRankListModel;
import com.yanqu.road.pb.activity.AutoSendRewardProto;
import com.yanqu.road.server.manager.tradewar.CrossTradeWarRankMgr;


/**
 * @author ：zfr
 * @date ：2021/8/9 18:45
 */
public class CrossTradeWarRank extends BaseCrossRank {

    public CrossTradeWarRank(int activityId) {
        super(activityId);
    }

    @Override
    public AutoSendRewardProto.CrossUserRankMsg.Builder getCrossUserRankMsg() {
        AutoSendRewardProto.CrossUserRankMsg.Builder msg = AutoSendRewardProto.CrossUserRankMsg.newBuilder();
        msg.setActivityId(activityId);
        CrossActivityRankListModel rankListModel = CrossTradeWarRankMgr.getCrossActivityRankListModel(activityId);
        if (rankListModel != null) {
            int conditionType = eGamePlayerEventType.CrossTradeWarScoreRiseRank.getValue();
            int rank = 0;
            for (CrossUserRank rankData : rankListModel.getRankList()) {
                long userId = rankData.getUserId();
                rank++;
                addUserRankData(msg, conditionType, userId, rank);
            }
        }
        return msg;
    }

    @Override
    public AutoSendRewardProto.CrossUnionRankMsg.Builder getCrossUnionRankMsg() {
        AutoSendRewardProto.CrossUnionRankMsg.Builder msg = AutoSendRewardProto.CrossUnionRankMsg.newBuilder();
        msg.setActivityId(activityId);
        CrossActivityUnionRankListModel rankListModel = CrossTradeWarRankMgr.getCrossActivityUnionRankListModel(activityId);
        if (rankListModel != null) {
            int conditionType = eGamePlayerEventType.CrossTradeWarUnionScoreRiseRank.getValue();
            int rank = 0;
            for (UnionActivityRank rankData : rankListModel.getRankList()) {
                String unionUid = rankData.getUnionUid();
                rank++;
                addUnionRankData(msg, conditionType, unionUid, rank);
            }
        }
        return msg;
    }
}
